<?php
/**
 *  $version $Id: mod_vm_categoryshortcut.php 9 2010-03-28 17:32:13Z webbochsant $
 *  @package	Joomla
 *  @author Daniel Eliasson
* 	@copyright	Copyright (C) 2010 Stilero. All rights reserved.
* 	@license	GNU/GPL, see LICENSE.php
* 	Joomla! is free software. This version may have been modified pursuant
* 	to the GNU General Public License, and as distributed it includes or
* 	is derivative of works licensed under the GNU General Public License or
* 	other free or open source software licenses.
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

// Include the syndicate functions only once
require_once (dirname(__FILE__).DS.'helper.php');

// Load the virtuemart main parse code
if( file_exists(dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' )) {
	require_once( dirname(__FILE__).'/../../components/com_virtuemart/virtuemart_parser.php' );
	$mosConfig_absolute_path = realpath( dirname(__FILE__).'/../..' );
} else {
	require_once( dirname(__FILE__).'/../components/com_virtuemart/virtuemart_parser.php' );
}
require_once(CLASSPATH.'ps_product_category.php');
$ps_product_category = new ps_product_category();

//Check if chache is activated
if ($params->get('cache')){
	$cache =& JFactory::getCache('mod_vm_categoryshortcut');
	$cache->setCaching( 1 );
	$method = array('ps_product_category', 'getCategoryTreeArray');
	$categories = $cache->call($method);
	$list = $ps_product_category->sortCategoryTreeArray($categories);
}else{
	$categories = $ps_product_category->getCategoryTreeArray();
	$list = $ps_product_category->sortCategoryTreeArray($categories);
}

// check if any results returned
//$items = count($list);
if (count($list)==0) {
	return;
}

$layout = $params->get('layout', 'shortcut');
//$layout = "default";
$path = JModuleHelper::getLayoutPath('mod_vm_categoryshortcut', $layout);
if (file_exists($path)) {
	require($path);
}

?>